package com.yc.springcloud.controller;

import com.yc.springcloud.service.StorageService;
import com.yc.springcloud.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @Author DELL
 * @Date 2024/11/19 15:55
 * @Version 1.0
 */
@Slf4j
@Controller
public class StorageController {

	@Resource
	private StorageService storageService;

	@ResponseBody
	@PostMapping("/storage/reduce")
	public Result reduce(@RequestParam("productId") Long productId, @RequestParam("nums") Integer nums) {

		log.info("===StorageController reduce start===");
		storageService.reduceProduct(productId, nums);
		return Result.success("扣减库存成功 ok", null);
	}

}
